home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-01-16 | 1.8 KB | 84 lines | [TEXT/PJMM] |
- program Assignment5;
- uses
- {$ifc UNDEFINED THINK_PASCAL}
- Types, QuickDraw, Menus, Windows, TextEdit, Fonts, Dialogs, Memory, OSEvents, {}
- {$endc}
- SAT;
-
- const
- kSpeed = 5;
- var
- ignore: SpritePtr;
- direction: Integer;
- theSound: Handle;
-
- procedure HandleSprite (me: SpritePtr);
- begin
- GetMouse(me^.position);
- end; {HandleSprite}
-
- procedure SetupSprite (me: SpritePtr);
- begin
- me^.task := @HandleSprite;
- me^.face := SATGetFace(128);
- SetRect(me^.hotRect, 0, 0, 32, 32);
- end; {SetupSprite}
-
- procedure SetupTarget (me: SpritePtr);
- forward;
-
- procedure HandleTarget (me: SpritePtr);
- begin
- me^.position.h := me^.position.h + direction;
- if me^.position.h <= 0 then
- direction := kSpeed;
- if me^.position.h >= 200 then
- direction := -kSpeed;
- end; {HandleTarget}
-
- procedure HitTarget (me, him: SpritePtr);
- begin
- if him^.task = @HandleSprite then {Chack what we hit!}
- begin
- me^.task := nil;
- ignore := SATNewSprite(-1, 0, SATRand(gSAT.offSizeV), @SetupTarget);
- {We could also re-use the old sprite for a new one, if we like.}
- SATSoundPlay(theSound, 1, true);
- end;
- end; {HandleTarget}
-
- procedure SetupTarget (me: SpritePtr);
- begin
- me^.task := @HandleTarget;
- me^.hitTask := @HitTarget;
- me^.face := SATGetFace(129);
- SetRect(me^.hotRect, 0, 0, 32, 32);
- direction := kSpeed;
- end; {SetupTarget}
-
- const
- kTicksPerFrame = 2;
- var
- t: Longint;
-
- begin
- {$ifc UNDEFINED THINK_PASCAL}
- SATInitToolbox;
- {$endc}
-
- SATConfigure(false, kVPositionSort, kForwardCollision, 32);
- SATInit(128, 129, 478, 302);
- ignore := SATNewSprite(0, 200, 200, @SetupSprite);
- ignore := SATNewSprite(0, 0, SATRand(gSAT.offSizeV), @SetupTarget);
- theSound := SATGetNamedSound('TestSound');
- HideCursor;
- while not Button do
- begin
- t := TickCount;
- SATRun(true);
- while TickCount < t + kTicksPerFrame do
- ;
- end;
- ShowCursor;
- SATSoundShutup;
- end.